package com.sgb.kjwl.view.ui.activity.home;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import android.view.View;

import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityHomePowerBinding;
import com.sgb.kjwl.view.ui.fragment.home.PowerFragment;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.di.AppComponent;

public class HomePowerActivity extends AppActivity {
    public static final int POWER = 0;
    private ActivityHomePowerBinding binding;
    private FragmentManager fragmentManager;
    private Fragment myFragment[] = new Fragment[1];
    private int currentIndex = 0;

    public static void start(Context context) {
        Intent intent = new Intent();
        intent.setClass(context, HomePowerActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        context.startActivity(intent);
    }

    @Override
    protected boolean statusBarDark() {
        return true;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initFragment(savedInstanceState);
    }

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {

    }

    @Override
    protected void initView() {
        binding = DataBindingUtil.setContentView(HomePowerActivity.this, R.layout.activity_home_power);
        binding.setViewModel(new BaseViewModel());
        binding.include.backView.setOnClickListener(this);
        binding.include.titleView.setText("建设力量");
    }

    private void initFragment(Bundle savedInstanceState) {
        if (savedInstanceState == null) {
            fragmentManager = getSupportFragmentManager();
            myFragment[POWER] = PowerFragment.newInstance("建设力量");
            fragmentManager.beginTransaction().add(R.id.content, myFragment[POWER]).commit();
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.back_view:
                finish();
                break;
        }
    }

    @SuppressLint("MissingSuperCall")
    @Override
    protected void onSaveInstanceState(Bundle outState) {
//        super.onSaveInstanceState(outState);
    }
}

